package com.turing.post.test;

import java.util.Properties;

import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class mdbtest {
	public static void main(String[] args) throws Exception {
    QueueConnection cnn = null;
    QueueSender sender = null;
    QueueSession sess = null;
    Queue queue = null;
     
    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    props.put(Context.PROVIDER_URL, "t3://localhost:7001");
    try {
        InitialContext ctx = new InitialContext(props);
        QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("weblogic.jms.ConnectionFactory");
        cnn = factory.createQueueConnection();
        sess = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
        queue = (Queue) ctx.lookup("DayOffImplQueue");
        TextMessage msg = sess.createTextMessage("961850");
        sender = sess.createSender(queue);
        sender.send(msg);
        System.out.println("send complete!");
        sess.close();
        System.out.println("close complete!");
        cnn.close();
    } catch (NamingException e) {
        e.printStackTrace();
    } catch (JMSException e) {
        e.printStackTrace();
    }

    System.out.println("ok!!!");
    //System.exit(0);
}
}